//
//  CodeExample.h
//  LSCodeLibrary
//
//  Created by Samuel on 15/4/1.
//  Copyright (c) 2015年 Samuel. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


//MBLog 全局开关
#define LOG 0

#if LOG
#define MBLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define MBLog(fmt, ...)
#endif

//颜色
#define kUIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
/*------------------------------------------------------------------------------------*/
@interface ShareObject : NSObject
/**
 *  单例
 *
 *  @return none
 */
+(instancetype)ShareSingleton;

@end
/*------------------------------------------------------------------------------------*/
@interface CodeExample : UIViewController

/**
 *  遍历UITableView上的所有Cell
 *
 *  @param NSIndexPath UIView
 *
 *  @return IndexPath
 */
+ (NSIndexPath *)SubView:(UIView *)subview TableView:(UITableView *)tableView;

@end
/*------------------------------------------------------------------------------------*/
@interface NSString (Hash)
/**
 *  MD5加密
 *
 *  @return
 */
-(NSString*)MD5String;
-(NSString*)urlencode;

-(id)JSONObject;

-(NSString*)resourcePath;
-(NSData*)readData;
-(NSString*)readString;

@end
/*------------------------------------------------------------------------------------*/
@interface UIView (BarButtonItem)

-(UIBarButtonItem*)barButtonItem;
-(void)removeAllSubviews;
-(void)runTask:(dispatch_block_t)block;

@end
/*------------------------------------------------------------------------------------*/
@interface UIButton (ImageButton)

+(instancetype)buttonWithImage:(NSString*)image;

@end
/*------------------------------------------------------------------------------------*/
@interface UIImageView (WebImage)

-(NSString*)filePathForImageURL:(NSString*)urlstring;
-(void)setImageURL:(NSString*)urlstring;
-(NSString*)getImageURL;
-(void)fetchImageFromURL:(NSString*)urlstring;

@end
/*------------------------------------------------------------------------------------*/
@interface NibLoader : NSObject

@property(nonatomic,strong)IBOutlet UIView *nibView;

+(UIView*)loadNib:(NSString*)nibName;
+(UIView*)loadNib:(NSString*)nibName bundle:bundle;

@end
/*------------------------------------------------------------------------------------*/
@interface WebService : NSObject

@property(nonatomic,strong)NSError *error;
@property(nonatomic,strong)id response;

+(instancetype)serviceWithApi:(NSDictionary*)api;
-(void)setApi:(NSDictionary*)api;
-(void)execute;

@end
/*------------------------------------------------------------------------------------*/
@interface NSArray (List)

-(BOOL)containsString:(NSString*)string;
-(NSArray*)arrayByRemoveNullValue;
-(NSString*)JSONString;

@end
/*------------------------------------------------------------------------------------*/
@interface NSDictionary (List)

-(NSDictionary*)dictionaryByRemoveNullValue;
-(NSString*)JSONString;

@end
/*------------------------------------------------------------------------------------*/
@interface NSObject (Payload)

@property(nonatomic,strong)id payloadObject;

@end
/*------------------------------------------------------------------------------------*/
@interface NSData (JSON)

-(id)JSONObject;

@end

